﻿$(function () {//预执行函数

});










//************************
var txy = {}; //命名空间










//***********************
txy.tools = {}; //工具类库
txy.tools.getNumMax = function (arr_or_a,b,c) {//取得一组number类型的数的最大值（利用重载函数）
    if(arguments.length==1){
        var max = arr_or_a[0];
        for (var i = 1; i < arr_or_a.length; i++) {
            if (max < arr_or_a[i]) { 
                max=arr_or_a[i];
            }
        }
        return max;
    }
    if(arguments.length==3){
        var max = arr_or_a;
        if (max< b)
        { max = b; }
        if (max < c)
        { max = c; }
        return max;
    }
    return null;
};
txy.tools.getUrlParameterValue = function (name) {//获得url路径后的参数
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
};
txy.tools.getDIYDate = function getDIYDate(date) {//得到自定义的日期格式
    var weeks = ["日", "一", "二", "三", "四", "五", "六"];
    var year = date.getFullYear() + "年";
    var month = date.getMonth() + 1 + "月";
    var day = date.getDate() + "日";
    var week = " 星期" + weeks[date.getDay()];
    var hour = date.getHours();
    var am = hour > 12 ? " 下午 " : " 上午 ";
    //hour = hour > 12 ? hour - 12 : hour;
    hour > 10 ? hour + "" : "0" + hour;
    var min = date.getMinutes();
    min = min < 10 ? "0" + min : min + "";
    var seconds = date.getSeconds();
    seconds = seconds < 10 ? "0" + seconds : "" + seconds;

    var str =month + day +"_"+ week + "_"+hour + " : " + min ;
    return str;
};
txy.tools.bubblesort = function (arr) {//冒泡排序法来排序一个number类型的数组
    for (var n = 1; n <= arr.length-1; n++) {
        for (var i = 0; i < arr.length - n; i++) {
            if (arr[i] < arr[i + 1]) {
                var temp = arr[i];
                arr[i] = arr[i + 1];
                arr[i + 1] = temp;
            }
        }
    }
};
txy.tools.sortByComplete = function (arr) { //封装比较器，来排序数组
    function complete() {
        return a - b;
    };
    arr.sort(complete);
};
txy.tools.strIsEmpty = function () { //判断字符串是否为空，或者空格字符串
    if (str === undefined) {
        return true;
    }
    else {
        if (str == null) {
            return true;
        }
        else {
            var rule = /^\s*$/;
            return rule.test(str);
        }
    }
};
txy.tools.getDomElementsByClass = function (parent, className) {//通过类名称得到一组dom对象
    var allElement = parent.getElementsByTagName("*");
    var arr = [];
    for (var i = 0; i < allElement.length; i++) {
        if (allElement[i].className.trim() == className.trim()) {
            arr.push(allElement[i]);
        }
    }
    return arr;
};
txy.tools.getJQElementsByClass = function (parent, className) {//通过类名称得到一组JQ对象
    parent = $(parent);
    var arr = parent.find("[class='"+className.trim()+"']");
    return arr;
};
txy.tools.createXmlHttpRequest=function(){//创建一个XMLHttpRequest(ajax)
    var xhr=null;
    if(window.XMLHttpRequest){
    //ie7,8,9 ff chrome
        xhr=new XMLHttpRequest();
    }
    else{
        //ie5.5,6
        xhr=new ActiveXObject("Microsoft.XMLHttp");
    }
    return xhr;
};
txy.tools.isEmail = function isEmail(str) { //验证email格式
    var reg = /^\w+((-w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
    return reg.test(str);
};
txy.tools.isPhone = function isPhone(str) { //验证手机号格式
    var reg = /^1[34578]\d{9}$/;
    return reg.test(str);
};









//************************
txy.ui = {}; //功能组件
txy.ui.deleteParent = function (child, count) {//删除父元素
    if (arguments.length == 1) {//只要删除父亲
        $(child).parent().remove();
    }
    if (arguments.length == 2) {//不光删除父亲，而且计数器减一
        $(child).parent().remove();
        count--;
        return count;
    }
    return null;
};
txy.ui.deleteConfirm = function () {//删除时确认
    $("a:contains('删除')").click(function () {
        return confirm("确定要删除?");
    });
};
txy.ui.jumpHtml = function (target, time) {//定时跳转页面
    var counter = time;
    var timer = null;
    function jump() {
        if (counter > 0) {
            counter--;
            document.getElementById("second").innerHTML = counter;
        }
        else {
            clearInterval(timer);
            location.href = target;
        }

    }
    timer = setInterval(jump, 1000);
};
txy.ui.toggleTitle = function () {//每两秒切换一次title
    var counter = 0;
    function changeTitle() {
        if (counter == 0) {
            document.title = "☆☆☆标题☆☆☆";
            counter++;
        }
        else {
            document.title = "★★★标题★★★";
            counter--;
        }
    }
    setInterval(changeTitle, 2000);
};
txy.ui.trChangeColor = function (table) {//指定的table的tr轮流变色
    table.find("tr:not(:first):odd").css("background-color", "#bbb");
    table.find("tr:not(:first):even").css("background-color", "#ddd");
};
txy.ui.textChange = function (obj, placeholder) {//文本框文字改变事件函数
    obj.onfocus = function () {
        if (this.value == placeholder) {
            this.value = "";
            this.style.color = "#000";
        }
    };
    obj.onblur = function () {
        if (this.value == "") {
            this.value = placeholder;
            this.style.color = "#aaa";
        }
    };
};
txy.ui.autoResizeIframeHeight = function (iframeId, minHeight) {//使得iframe根据子页面自适应height
    var browserVersion = window.navigator.userAgent.toUpperCase();
    var isOpera = false;
    var isFireFox = false;
    var isChrome = false;
    var isSafari = false;
    var isIE = false;
    var iframeTime;

    startInit(iframeId, minHeight);//调用一行代码即可

    function reinitIframe(iframeId, minHeight) {
        try {
            var iframe = document.getElementById(iframeId);
            var bHeight = 0;
            if (isChrome == false && isSafari == false) {
                bHeight = iframe.contentWindow.document.body.scrollHeight;
            }
            var dHeight = 0;
            if (isFireFox == true) {
                dHeight = iframe.contentWindow.document.documentElement.offsetHeight + 2;
            }
            else {
                if (isIE == false && isOpera == false) {
                    dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
                }
                else {
                    bHeight += 3;
                }
            }
            var height = Math.max(bHeight, dHeight);
            if (height < minHeight) {
                height = minHeight;
            }
            iframe.style.height = height + "px";
        } catch (ex) { }
    }
    function startInit(iframeId, minHeight) {
        isOpera = browserVersion.indexOf("OPERA") > -1 ? true : false;
        isFireFox = browserVersion.indexOf("FIREFOX") > -1 ? true : false;
        isChrome = browserVersion.indexOf("CHROME") > -1 ? true : false;
        isSafari = browserVersion.indexOf("SAFARI") > -1 ? true : false;
        if (!!window.ActiveXObject || "ActiveXObject" in window) {
            isIE = true;
        }
        reinitIframe(iframeId, minHeight);
        if (iframeTime != null) {
            clearInterval(iframeTime);
        }
        //iframeTime = setInterval("reinitIframe('" + iframeId + "'," + minHeight + ")", 100);
        //这种方式调用setInterval函数，只能执行在全局作用域下的函数。***************************
        iframeTime = setInterval(function () {
            try {
                var iframe = document.getElementById(iframeId);
                var bHeight = 0;
                if (isChrome == false && isSafari == false) {
                    bHeight = iframe.contentWindow.document.body.scrollHeight;
                }
                var dHeight = 0;
                if (isFireFox == true) {
                    dHeight = iframe.contentWindow.document.documentElement.offsetHeight + 2;
                }
                else {
                    if (isIE == false && isOpera == false) {
                        dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
                    }
                    else {
                        bHeight += 3;
                    }
                }
                var height = Math.max(bHeight, dHeight);
                if (height < minHeight) {
                    height = minHeight;
                }
                iframe.style.height = height + "px";
            } catch (ex) { }
        }, 100);
    }
};

/*********************************************基于formvalidator的表单验证***************************************/
//txy.ui.formvalidateByFormvalidator01 = function () {//此处注释是为了防止IE9报错，因为页面没有真正引入formValidator的js，所以这边的$会报错。
//    $.formValidator.initConfig({
//        validatorGroup:"1",
//    }); //初始化校验动作，告知要用formValidator这个插件
//    $("#userName").formValidator({//初始化提示信息
//        onShow: "请输入用户名",
//        onFocus: "字母，数字，下划线组成",
//        onEmpty: "用户名不允许为空"
//    }).inputValidator({//初始化验证规则
//        empty: { leftEmpty: false, rightEmpty: false, emptyError: "用户名左右不能为空格" },
//        min: 6,
//        max: 12,
//        onError: "用户名必须是6-12位"
//    }).regexValidator({//初始化正则
//        regExp: "^\\w+$",
//        onError: "请输入字母，数字，下划线"
//    });
//    $("#password").formValidator({//初始化提示信息
//        onShow: "请输入密码",
//        onFocus: "字母，数字组成,至少6位",
//        onEmpty: "密码不允许为空"
//    }).inputValidator({//初始化验证规则
//        empty: { leftEmpty: false, rightEmpty: false, emptyError: "密码左右不能为空格" },
//        min: 6,
//        onError: "密码至少6位"
//    }).regexValidator({//初始化正则
//        regExp: "^[A-Za-z0-9]+$",
//        onError: "请输入字母，数字"
//    });
//    $("#password2").formValidator({//初始化提示信息
//        onShow: "请重复密码",
//        onFocus: "字母，数字组成",
//        onEmpty: "密码不允许为空"
//    }).compareValidator({//初始化验证规则
//        desID: "password",
//        operateor: "=",
//        onError: "密码不吻合"
//    });
//    $("#idCardNum").formValidator({//初始化提示信息
//        onShow: "请输入身份证号",
//        onFocus: "输入15或18位身份证号",
//        onEmpty: "身份证号不允许为空"
//    }).inputValidator({//初始化验证规则
//        empty: { leftEmpty: false, rightEmpty: false, emptyError: "身份证号左右不能为空格" },
//        min: 15,
//        onError: "身份证至少15位"
//    }).functionValidator({//初始化函数验证--这是自带的函数
//        fun: isCardID
//    });
//    $("#email").formValidator({//初始化提示信息
//        onShow: "请输入电子邮箱",
//        onFocus: "格式:XXX@XXX.com",
//        onEmpty: "邮箱不允许为空"
//    }).inputValidator({//初始化验证规则
//        empty: { leftEmpty: false, rightEmpty: false, emptyError: "邮箱左右不能为空格" }
//    }).regexValidator({//初始化正则
//        regExp: "^([\\w-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([\\w-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$",
//        onError: "邮箱格式错误"
//    });
//    $("#education").formValidator({//初始化提示信息
//        onShow: "请选择学历",
//        onFocus: "学历不能为空",
//        onEmpty: "学历不允许为空"
//    }).inputValidator({//初始化验证规则
//        min: 1,
//        onError: "你忘记选学历了"
//    });
//    $("#phoneNum").formValidator({//初始化提示信息
//        onShow: "请输入手机号，可以为空",
//        onFocus: "请正确输入",
//        empty: true,
//        onEmpty: "你真的不想留手机号码啊？",
//        onCorrect: "谢谢你的合作"
//    }).inputValidator({//初始化验证规则
//        empty: { leftEmpty: false, rightEmpty: false, emptyError: "手机号左右不能为空格" },
//        min: 11,
//        max: 11,
//        onError: "手机号必须是11位"
//    }).regexValidator({//初始化正则
//        regExp: "^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\d{8}$",
//        onError: "手机号错误"
//    });
//};
/*********************************************基于formvalidator的表单验证***************************************/

/*********************************************基于jqueryUI的提示窗口********************************************/
txy.ui.jqUIShowPromptDialog = function (dialog, message, url) {
    if (arguments.length == 2) {
        $(dialog).html(message);
        $(dialog).dialog("open");
    }
    if (arguments.length == 3) {
        $(dialog).html(message);
        $(dialog).dialog("open");
        setTimeout(function () {
            $(dialog).dialog("close");
        }, 1500);
        setTimeout(function () {
            window.location.href = url;
        }, 2000);
    }
};
/*********************************************基于jqueryUI的提示窗口********************************************/

/******************************************amcharts报表插件******************************************************/
txy.ui.amChartsDrawPie = function (chartData) {//基于amcharts的饼状图绘制
    // PIE CHART
    chart = new AmCharts.AmPieChart();
    chart.dataProvider = chartData;
    chart.titleField = "key";
    chart.valueField = "value";
    chart.colorField = "color";
    chart.labelText = "[[title]]: \n[[percents]]%";
    chart.balloonText = "[[title]]<br><span style='font-size:1.4rem'><b>[[value]]</b> ([[percents]]%)</span>";
    // this makes the chart 3D
    chart.depth3D = 15;
    chart.angle = 30;
    chart.labelTickColor = "#fff";
    chart.labelTickAlpha = 1;
    chart.color = "#fff";
    chart.labelRadius = 15;
    // WRITE
    chart.startDuration = 2;//开始时的运动时间
    //chart.radius = 50;//设置图的大小，绝对的大小
    return chart;
};
txy.ui.amChartsDrawColumn = function (chartData) {//基于amcharts的柱状图绘制
    // SERIAL CHART
    chart = new AmCharts.AmSerialChart();
    chart.dataProvider = chartData;
    chart.categoryField = "key";
    // the following two lines makes chart 3D
    chart.depth3D = 20;
    chart.angle = 30;

    // AXES
    // category
    var categoryAxis = chart.categoryAxis;
    categoryAxis.labelRotation = 0;
    categoryAxis.dashLength = 1000;
    categoryAxis.gridPosition = "start";

    // value
    var valueAxis = new AmCharts.ValueAxis();
    valueAxis.title = null;
    valueAxis.dashLength = 5;
    //valueAxis.unit = "%";//设置左侧栏单位
    chart.addValueAxis(valueAxis);

    // GRAPH
    var graph = new AmCharts.AmGraph();
    graph.valueField = "value";
    graph.colorField = "color";
    graph.balloonText = "<span style='font-size:1.4rem'>[[category]]: <b>[[value]]</b></span>";
    graph.type = "column";
    graph.lineThickness = 1;
    graph.lineAlpha = .5;
    graph.fillAlphas = 1;
    chart.addGraph(graph);

    // CURSOR
    var chartCursor = new AmCharts.ChartCursor();
    chartCursor.cursorAlpha = 0;
    chartCursor.zoomable = false;
    chartCursor.categoryBalloonEnabled = false;
    chart.addChartCursor(chartCursor);

    chart.creditsPosition = "top-right";
    chart.color = "#fff";
    // WRITE
    chart.startDuration = 2;//刚开始的时候的运动时间

    return chart;
};
txy.ui.amChartsDrawFunnel = function (chartData) {//基于amcharts的金字塔图绘制
    chart = new AmCharts.AmFunnelChart();
    chart.dataProvider = chartData;
    chart.rotate = true;
    chart.titleField = "key";
    chart.valueField = "value";
    chart.colorField = "color";
    chart.balloon.fixedPosition = true;
    chart.marginRight = 100;
    chart.marginLeft = 50;
    chart.labelPosition = "right";
    chart.funnelAlpha = 1;
    chart.valueField = "value";
    chart.startX = -500;
    chart.startAlpha = 0;

    chart.color = "#fff";
    chart.labelTickColor = "#fff";
    chart.labelTickAlpha = 1;
    chart.startDuration = 2;//刚开始的时候的运动时间
    chart.balloonText = "[[title]]<br><span style='font-size:1.4rem'><b>[[value]]</b> ([[percents]]%)</span>";
    return chart;
};
txy.ui.amChartsDrawLineWithStar = function (chartData) {//基于amCharts的线图绘制
    var chart = new AmCharts.AmSerialChart();
    chart.dataProvider = chartData;
    chart.categoryField = "key";

    // sometimes we need to set margins manually
    // autoMargins should be set to false in order chart to use custom margin values
    chart.autoMargins = false;
    chart.marginRight = 0;
    chart.marginLeft = 30;
    chart.marginBottom = 6;
    chart.marginTop = 30;

    // AXES
    // category
    var categoryAxis = chart.categoryAxis;
    categoryAxis.inside = true;
    categoryAxis.gridAlpha = 0;
    categoryAxis.tickLength = 6;
    categoryAxis.axisAlpha = 1;
    categoryAxis.color = "#fff";


    // value
    var valueAxis = new AmCharts.ValueAxis();
    valueAxis.dashLength = 4;
    valueAxis.axisAlpha = 1;
    //设置左侧栏取值范围
    valueAxis.minimum = 0;
    valueAxis.maximum = 100;
    chart.addValueAxis(valueAxis);


    // GRAPH
    var graph = new AmCharts.AmGraph();
    graph.type = "line";
    graph.valueField = "value";
    graph.balloonText = "<span style='font-size:1.4rem'>[[value]]%</span>";
    graph.lineColor = "#D8E63C";
    graph.customBullet = "../../../js/rd/goodsTrans/images/star.png"; // bullet for all data points
    graph.bulletSize = 14; // bullet image should be a rectangle (width = height)
    graph.customBulletField = "customBullet"; // this will make the graph to display custom bullet (red star)
    chart.addGraph(graph);

    // CURSOR
    var chartCursor = new AmCharts.ChartCursor();
    chartCursor.cursorAlpha = .5;
    //chartCursor.cursorColor = "#fff";
    chartCursor.zoomable = true;
    chartCursor.categoryBalloonEnabled = true;
    //chartCursor.categoryBalloonColor = "green";
    chart.addChartCursor(chartCursor);

    chart.startDuration = 2;//刚开始的时候的运动时间
    chart.color = "#fff";
    return chart;
};
/******************************************amcharts报表插件******************************************************/

/******************************************数字滚动**************************************************************/
txy.ui.magicNumber = function ($Div, value) {//基于jquery的目标div中数字的滚动显示
    $Div.animate(
        { count: value },
        {
            duration: 1000,/*延迟1000毫秒*/
            step: function () {
                $Div.text(parseInt(this.count + 1));//此处加一，因为默认显示的数字就减一
            }
        }
    );
};
function NumbersAnimate(target, number, duration) {//定义一个NumbersAnimate类
    this.Target = target;
    this.Number = number;
    this.Duration = duration;
    this.Animate = function () { //初始化动画方法
        var array = this.Number.split("");
        //遍历数组
        for (var i = 0; i < array.length; i++) {
            var currentN = array[i];
            //数字append进容器
            var t = $("<span></span>");
            $(t).append("<span class=\"childNumber\">" + array[i] + "</span>");
            $(t).css("margin-left", 25 * i + "px"); //数字间距离
            $(this.Target).append(t);
            //生成滚动数字,根据当前数字大小来定
            for (var j = 0; j <= currentN; j++) {
                var tt;
                if (j == currentN) {
                    tt = $("<span class=\"main\"><span>" + j + "</span></span>");
                } else {
                    tt = $("<span class=\"childNumber\">" + j + "</span>");
                }
                $(t).append(tt);
                $(tt).css("margin-top", (j + 1) * 25 + "px");
            }
            $(t).animate(
                { marginTop: -((parseInt(currentN) + 1) * 25) + "px" },
                {
                    duration: this.Duration,//延迟
                    complete: function () { //完成之后的工作
                        $(this).find(".childNumber").remove();
                    }
                }
            );
        }
    };
    this.ChangeNumber = function (number) {
        var oldArray = this.Number.split("");
        var newArray = number.split("");

        for (var i = 0; i < oldArray.length; i++) {
            var o = oldArray[i];
            var n = newArray[i];
            if (o != n) {
                var c = $($(".main")[i]);
                var top = parseInt($($(c).find("span")[0]).css("marginTop").replace('px', ''));

                for (var j = 0; j <= n; j++) {
                    var nn = $("<span>" + j + "</span>");
                    if (j == n) {
                        nn = $("<span>" + j + "</span>");
                    } else {
                        nn = $("<span class=\"yy\">" + j + "</span>");
                    }
                    $(c).append(nn);
                    $(nn).css("margin-top", (j + 1) * 25 + top + "px");
                }
                var margintop = parseInt($(c).css("marginTop").replace('px', ''));
                $(c).animate(
                    { marginTop: -((parseInt(n) + 1) * 25) + margintop + "px" },
                    this.Duration,
                    function () {
                        $($(this).find("span")[0]).remove();
                        $(".yy").remove();
                    }
                );
            }
        }
        this.Number = number;
    };
};
/******************************************数字滚动**************************************************************/

/******************************************动画处理部分**********************************************************/
txy.ui.fadeIn = function (obj) {//淡入函数（1秒）50*(100/5)=1000ms
    var value = 0;
    clearInterval(obj.timer);
    obj.timer = setInterval(function () {
        var speed = 5;
        if (value == 100) {
            clearInterval(obj.timer);
        }
        else {
            value += speed;
            obj.style.opacity = value / 100;
            obj.style.filter = "alpha(opacity=" + value + ")";
        }
    }, 50);

};
txy.ui.fadeOut = function (obj) {//淡出函数（1秒）50*(100/5)=1000ms
    var value = 100;
    clearInterval(obj.timer);
    obj.timer = setInterval(function () {
        var speed = -5;
        if (value == 0) {
            clearInterval(obj.timer);
        }
        else {
            value += speed;
            obj.style.opacity = value / 100;
            obj.style.filter = "alpha(opacity=" + value + ")";
        }
    }, 50);
};
txy.ui.oldMoveNow = function (obj, old, now) {//跑马灯的点击后的缓冲位移函数
    clearInterval(obj.timer);
    obj.timer = setInterval(function () {
        var speed = (now - old) / 10;//缓冲处理
        speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);
        if (now == old) {
            clearInterval(obj.timer);
        }
        else {
            old += speed;
            obj.style.left = old + "px";
        }
    }, 30);
};
txy.ui.startMove = function (obj, json, fnEnd) {//运动函数
    if (obj.timer) {
        clearInterval(obj.timer);
    }
    obj.timer = setInterval(function () {
        doMove(obj, json, fnEnd);
    }, 60);

    var oDate = new Date();

    if (oDate.getTime() - obj.lastMove > 60) {
        doMove(obj, json, fnEnd);
    }


    function getStyle(obj, attr) {//为startMove函数服务
        if (obj.currentStyle) {
            return obj.currentStyle[attr];
        }
        else {
            return getComputedStyle(obj, false)[attr];
        }
    }
    function doMove(obj, json, fnEnd) {//为startMove函数服务
        var iCur = 0;
        var attr = '';
        var bStop = true;	//假设运动已经该停止了

        for (attr in json) {
            if (attr == 'opacity') {
                iCur = parseInt(100 * parseFloat(getStyle(obj, 'opacity')));
            }
            else {
                iCur = parseInt(getStyle(obj, attr));
            }

            if (isNaN(iCur)) {
                iCur = 0;
            }

            var iSpeed = (json[attr] - iCur) / 8;
            iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);

            if (parseInt(json[attr]) != iCur) {
                bStop = false;
            }

            if (attr == 'opacity') {
                obj.style.filter = "alpha(opacity:" + (iCur + iSpeed) + ")";
                obj.style.opacity = (iCur + iSpeed) / 100;
            }
            else {
                obj.style[attr] = iCur + iSpeed + 'px';
            }
        }

        if (bStop) {
            clearInterval(obj.timer);
            obj.timer = null;

            if (fnEnd) {
                fnEnd();
            }
        }

        obj.lastMove = (new Date()).getTime();
    }
};
/******************************************动画处理部分**********************************************************/

/*************************************基于第三方地图开发http://58.49.53.42:9006/api-js/      PS：基于高德地图***********************************************************/
txy.ui.configureMap = function () {//配置地图
    var x = txy.tools.getUrlParameterValue("x");
    var y = txy.tools.getUrlParameterValue("y");

    mapCenter = { x: x, y: y };//地图中心
    defaultLevel = 6;//缩放级别
    defaultImgSrc = "http://58.49.53.42:9006/gisapi/resources/images/gis/icon/marker_large.png";
};
txy.ui.initMap = function (containerId, callback) {//初始化地图
    //定义地图对象
    var options = {
        center: new beyond.geometry.MapPoint(mapCenter.x, mapCenter.y),//地图中心
        zoom: defaultLevel,//缩放级别
        minZoom: 0,//最小缩放级别
        maxZoom: 17//最大缩放级别
    };
    var map = new beyond.maps.Map(containerId, options, callback);
    return map;
};
/*************************************基于第三方地图开发http://58.49.53.42:9006/api-js/      PS：基于高德地图***********************************************************/

/*****************************************************基于H-UI框架***********************************************************/
txy.ui.hui_PageHeaderContextMenuReset = function () {//H-UI页头右击菜单重置
    $(".Hui-tabNav-wp li").contextMenu('myMenu1', {
        bindings: {
            'refresh': function (a) {
                var href = $(a).find("span").attr("data-href");//要刷新的url

                $(a).click();//先使得点击的页头对应的页面先展示出来
                if (href != undefined) {
                    $("#iframe_box iframe").each(function () {
                        var item = this;
                        if ($(item).attr("src").trim() == href) {
                            item.contentWindow.location.reload(true);
                        }
                    });
                }
            },
            'closeCurrent': function (a) {
                $(a).find("i").click();
            },
            'closeOther': function (a) {
                $(a).siblings().find("i").click();
            },
            'closeAll': function (a) {
                $(a).parent().find("li").find("i").click();
            }
        }
    });
};
/*****************************************************基于H-UI框架***********************************************************/










//***********************
txy.app = {}; //功能实现












//*********************************************Jq扩展******************************************************************
/*将form的数据转换为json格式的对象，$("#form1").serialize();只会返回key1=value1&key2=value2这样的格式的字符串*/
$.fn.serializeObject = function () {
    var o = {};
    var a = this.serializeArray();
    $.each(a, function () {
        if (o[this.name]) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });
    return o;
};





